#!/bin/sh

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

export JAVA_HOME=/usr/java/jdk1.6.0_45
export CLASSPATH=.:$JAVA_HOME/lib:/jre/lib:$CLASSPATH
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$HOMR/bin::$ANT_HOME/bin

resindir='/usr/local/resin'
url='http://localhost:8080/web/lb/category_list'
logfile=/tmp/lbfonterror.log

#重启resin
/etc/init.d/lbfont restart 
sleep 30s

num=0
while [[ $num -le 6 ]]
do
    #请求测试url,得到返回状态吗
    code=$(curl -s -o $logfile -m 10 --connect-timeout 10 $url -w %{http_code})
    if [ $code -eq 200 ]
    then
        #如果返回200
        echo "[success]页面返回码为$code,resin启动成功,测试页面正常......"
	break
    else
        if [ $num -eq 6 ]
        then
            echo "[error]resin页面出错,请注意......状态码为$code,错误日志已输出到$logfile"
        fi
    fi

    num=$[ $num + 1 ]
    sleep 5s
done
